import torch
import numpy
import threading
import queue
from time import sleep


def producer(q: queue.Queue):
    for i in range(10):
        q.put(i)
        sleep(5)


def consumer(q: queue.Queue):
    while True:
        print(q.get())
        q.task_done()


q = queue.Queue()
t1 = threading.Thread(target=consumer, args=(q,), daemon=True)
t2 = threading.Thread(target=consumer, args=(q,), daemon=True)

t1.start()
t2.start()

producer(q)
q.join()
